package syncAsync;

import java.io.UnsupportedEncodingException;

import com.alibaba.rocketmq.client.exception.MQBrokerException;
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.common.message.Message;
import com.alibaba.rocketmq.remoting.common.RemotingHelper;
import com.alibaba.rocketmq.remoting.exception.RemotingException;

public class SyncProducer {
public static void main(String[] args) throws MQClientException, RemotingException, MQBrokerException, InterruptedException, UnsupportedEncodingException {
	DefaultMQProducer producer=new DefaultMQProducer("syncProducer");
	producer.setNamesrvAddr("127.0.0.1:9876");
	producer.setInstanceName("syncProducer-instance");
	producer.setVipChannelEnabled(false);
	producer.start();
	for(int i=0;i<100;i++){
		Message msg=new Message("TopicTest","TagA",("Hello RocketMQ"+i).getBytes(RemotingHelper.DEFAULT_CHARSET));
		SendResult sendResult=producer.send(msg);
		System.out.printf("%s-%n",sendResult);
	}
	producer.shutdown();



}
}
